package games;

import javax.swing.*;
import java.util.Scanner;

public class ClassicProperty extends Property{

    int homes;//number of homes on property
    int hotels;//number of hotels on property
    double homePrice;
    double hotelPrice;
    double homeRent;
    double hotelRent;

    public ClassicProperty(String n, int g, double p, double r, double r2, double hp, double op, double hr, double or){
        super(n,g,p,r,r2);
        homePrice = hp;
        hotelPrice = op;
        homeRent = hr;
        hotelRent = or;

        homes = 0;
        hotels = 0;
    }

    double calculateRent(){
        double curRent = 0;
        if (groupComplited){
            curRent = rent2;
            curRent += homeRent*homes;
            curRent += hotelRent*hotels;
        }
        else {
            curRent = rent1;
        }

        return curRent;
    }

    @Override
    void onMyProperty() {
        if (this.groupComplited){

            int choice;
            super.onMyProperty();
            System.out.println("Do you wanna buy any item?  (1)home/(2)hotel/(3)none");

            Object[] options = {"Buy Home",
                    "Buy Hotel",
                    "None"};
            choice = JOptionPane.showOptionDialog(new JFrame(),
                    "Do you wanna buy any item",
                    "group owner question",
                    JOptionPane.YES_NO_CANCEL_OPTION,
                    JOptionPane.QUESTION_MESSAGE,
                    null,
                    options,
                    options[2]);

            switch (choice) {
                case 1:
                    owner.loseMoney(homePrice);
                    homes++;
                    break;
                case 2:
                    owner.loseMoney(hotelPrice);
                    hotels++;
                    break;
                case 3:
                    System.out.println(owner.getPlayerName() + " I dont wanna buy any item");
                    break;
                default:
                    System.out.println("Do nothing please choose one of offered options.");
                    break;

            }
        }
    }
}
